Jump to content

- Functions

- # GetUserStatus()

  Followers 0

  Lua → VBScript

  This function returns the current status of the given user.

  Please see the Introduction chapter for some usage instructions.

      ------------------------------------------------------------------
      -- GetUserStatus
      --
      -- Returns the status of the given user.
      -- If being used on a user group it returns the status of the last user in the group.
      --
      -- Parameter:
      --      sNumber     extension of user or user group
      --
      -- Return:
      --      number - PBXUserStateValue
      --
      --      PBXUserStateUnavailable      = 0   -- no mutual status signalling configured
      --      PBXUserStateLoggedOff        = 1   -- logged off
      --      PBXUserStateLoggedOn         = 2   -- logged on and free
      --      PBXUserStateSpeakingExternal = 3   -- busy externally
      --      PBXUserStateAlerting         = 4   -- currently altering/rinbing
      --      PBXUserStateSpeakingInternal = 5   -- busy internally
      --      PBXUserStateAway             = 6   -- away status active
      --      PBXUserStateDoNotDisturb     = 7   -- do not disturb (DND) status active
      --      PBXUserStateActive3rdParty   = 8   -- busy indication from external presence source (e.g. MS Teams)
      ------------------------------------------------------------------
      function GetUserStatus(sNumber)
          PBXScript.OutputTrace ("-------------> GetUserStatus(sNumber = " .. sNumber .. ")")

          local nReturn = 0
          local oUsers  = nil

          oUsers = PBXScript.GetUserByAddress(sNumber)
          if (oUsers ~= nil) then

              for i = 1, #oUsers do

                  PBXScript.OutputTrace ("Found user " .. oUsers[i]:Name() .. " with current state " .. oUsers[i]:State())

                  nReturn = oUsers[i]:State()

              end

          end

          PBXScript.OutputTrace ("nReturn = " .. nReturn)
          PBXScript.OutputTrace ("<------------- GetUserStatus")

          return nReturn
      end

  This function makes use of the Server Script API functions PBXConfig.GetUserByAddress() to resolve the user state and PBXScript.OutputTrace() to write trace information into the SwyxServer trace file.

  This function was converted from VBScript into Lua from the initially posted version in this forum topic.

  By Tom Wellige

  - June 5, 2022
  Share
  Share
  Followers 0
  Previous Page GetUserNameFromExtension()
  Next Page IsAtLeastOneMemberOfGroupBusy()

## Important Information

By using this site, you agree to our Terms of Use and have taken note of our Privacy Policy.
We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.